<?php
    include "test.php";    

    if (array_key_exists("xslt", $_GET)) {
        header('Content-Type: text/xml');
        echo <<< qqq
<?xml version="1.0" encoding="utf-8"?>
$res
qqq;
    } else {
        $xslDoc = new DOMDocument();
        $xslDoc->load("test.xsl");
        
        $xmlDoc = new DOMDocument();
        $xmlDoc->loadXML($res);

        $proc = new XSLTProcessor();
        $proc->importStylesheet($xslDoc);
        echo $proc->transformToXML($xmlDoc);
    }
?>